import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

const register = () => import("../page/register/register.vue")
const login = () => import("../page/login/login.vue")
const index = () => import("../page/index/index.vue")
const goods = () => import("../page/goods/goods.vue")
const search = () => import("../page/search/search.vue")
const detail = () => import("../page/detail/detail.vue")
const order = () => import("../page/order/order.vue")
const address = () => import("../page/address/address.vue")
const addressAdd = () => import("../page/addressAdd/addressAdd.vue")
const pay = () => import("../page/pay/pay.vue")

const home = () => import("../page/index/components/home.vue")
const sort = () => import("../page/index/components/sort.vue")
const shop = () => import("../page/index/components/shop.vue")
const mine = () => import("../page/index/components/mine.vue")

const routes = [{
  path: "/",
  component: index,
  children: [{
    path: "home",
    component: home
  }, {
    path: "sort",
    component: sort
  }, {
    path: "shop",
    component: shop
  }, {
    path: "mine",
    component: mine
  }, {
    path: "",
    redirect: "home"
  }]
}, {
  path: "/login",
  component: login
}, {
  path: "/register",
  component: register
}, {
  path: "/goods",
  component: goods
}, {
  path: "/search",
  component: search
}, {
  path: "/detail",
  component: detail
}, {
  path: "/order",
  component: order
}, {
  path: "/address",
  component: address
}, {
  path: "/addressAdd",
  component: addressAdd
}, {
  path: "/pay",
  component: pay
}, {
  path: "/undefind",
  component: () => import("../page/404/404.vue")
}, {
  path: "*",
  redirect: "undefined"
}]

const router = new VueRouter({
  routes
})

export default router